using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using JGSY.CMS.LowCode.Platform.Domain.Interfaces;

namespace JGSY.CMS.LowCode.Platform.Domain.Entities
{
    /// <summary>
    /// 双因子认证配置实体
    /// 用于存储用户的双因子认证设置和密钥信息
    /// </summary>
    [Table("TwoFactors")]
    public class TwoFactor : ITenantEntity
    {
        /// <summary>
        /// 双因子认证记录标识符
        /// </summary>
        [Key]
        public long Id { get; set; }

        /// <summary>
        /// 用户标识符
        /// 该双因子认证配置关联的用户ID
        /// </summary>
        [Required]
        public long UserId { get; set; }

        /// <summary>
        /// 密钥
        /// 用于生成TOTP验证码的密钥
        /// </summary>
        [Required]
        public string SecretKey { get; set; } = string.Empty;

        /// <summary>
        /// 备份验证码
        /// 以JSON格式存储的备份验证码列表
        /// </summary>
        public string? BackupCodes { get; set; }
        
        /// <summary>
        /// 创建时间
        /// 双因子认证配置的创建时间戳
        /// </summary>
        public DateTime CreatedAt { get; set; }
        
        /// <summary>
        /// 最后验证时间
        /// 用户最后一次成功验证双因子认证的时间
        /// </summary>
        public DateTime? LastVerifiedAt { get; set; }
        
        /// <summary>
        /// 是否启用
        /// 标识该用户的双因子认证是否处于启用状态
        /// </summary>
        public bool IsEnabled { get; set; }
        
        /// <summary>
        /// 备注信息
        /// 双因子认证配置的额外说明或标注
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 租户标识符
        /// </summary>
        public string TenantId { get; set; } = string.Empty;
    }
}
